//
//  TIMNewFriendCell.m
//  Demo_sdk
//
//  Created by Deli Xia on 2018/6/30.
//  Copyright © 2018年 Deli Xia. All rights reserved.
//

#import "TIMNewFriendCell.h"
#import "TIMDemoMacro.h"

@implementation TIMNewFriendCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self configUI];
    }
    return self;
}
/*
 @property (nonatomic,strong) UIImageView *iconImgView;//!< 头像
 @property (nonatomic,strong) UILabel *NameLab;//!< 姓名
 @property (nonatomic,strong) UILabel *remarksLab;//!< 备注文案
 @property (nonatomic,strong) UIButton *accessBtn;//!< 添加与否
 */

- (void)configUI
{
    [self.contentView addSubview:self.iconImgView];
    [self.contentView addSubview:self.NameLab];
    [self.contentView addSubview:self.remarksLab];
    [self.contentView addSubview:self.accessBtn];
    [self.contentView addSubview:self.accessLab];
    [self.contentView addSubview:self.lineView];
}

- (void)setFriendmodel:(TIMUserInfo *)friendmodel
{
    _friendmodel = friendmodel;
    if (_friendmodel.showName.length > 0) {
        _NameLab.text = _friendmodel.showName;
        
    } else {
        _NameLab.text = _friendmodel.userID;
    }
    _remarksLab.text = _friendmodel.showName;
//    NSString *url;
//    if ([friendmodel.headurl hasPrefix:@"http"]) {
//        url = friendmodel.headurl;
//    } else {
//        url = [NSString stringWithFormat:@"http://%@",friendmodel.headurl];
//    }
//    [_iconImgView sd_setImageWithURL:[url filterChineseAndThin] placeholderImage:kLOADIMAGE(@"userNorm_image")];
    [_iconImgView setImage:[UIImage imageNamed:@"tab_mine_unselect"]];
    
    if ([_friendmodel.status isEqualToString:@"1"]) {
        _accessBtn.hidden = YES;
        _accessLab.hidden = NO;
        
    } else {
        _accessBtn.hidden = NO;
        _accessLab.hidden = YES;
    }
    
}
- (UIImageView *)iconImgView
{
    if (!_iconImgView) {
        _iconImgView = [[UIImageView alloc] initWithFrame:CGRectMake(15, 10, 40, 40)];
        _iconImgView.layer.cornerRadius = _iconImgView.frame.size.height/2;
        _iconImgView.layer.masksToBounds = YES;
    }
    return _iconImgView;
}

- (UILabel *)NameLab
{
    if (!_NameLab) {
        _NameLab = [[UILabel alloc] initWithFrame:CGRectMake(70, 10, Screen_Width - 150, 20)];
        _NameLab.font = TPSFontSize(14);
        
    }
    return _NameLab;
}
- (UILabel *)remarksLab
{
    if (!_remarksLab) {
        _remarksLab = [[UILabel alloc] initWithFrame:CGRectMake(70, 30, Screen_Width - 150, 20)];
        _remarksLab.font = TPSFontSize(12);
        _remarksLab.textColor = RGBColor(170, 170, 170);
        
    }
    return _remarksLab;
}
- (UIButton *)accessBtn
{
    if (!_accessBtn) {
        _accessBtn = [[UIButton alloc] initWithFrame:CGRectMake(Screen_Width - 55 - 20, 35/2, 55, 25)];
        [_accessBtn setTitle:@"接受" forState:UIControlStateNormal];
        _accessBtn.titleLabel.font = TPSFontSize(14);
        _accessBtn.backgroundColor=  RGBColor(88, 144, 240);
        _accessBtn.layer.cornerRadius = 25/2;
        [_accessBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        
    }
    return _accessBtn;
}

- (UILabel *)accessLab
{
    if (!_accessLab) {
        _accessLab = [[UILabel alloc] initWithFrame:CGRectMake(Screen_Width - 55 - 20, 35/2, 55, 25)];
        _accessLab.font = TPSFontSize(14);
        _accessLab.text = @"已添加";
        _accessLab.textColor = [UIColor blueColor];
        _accessLab.textAlignment = NSTextAlignmentCenter;
    }
    return _accessLab;
}
- (UIView *)lineView
{
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, 60 - 1, Screen_Width, 1)];
        _lineView.backgroundColor = [UIColor blackColor];
    }
    return _lineView;
}

@end
